import { ref } from 'vue'
import type { Ref } from 'vue'
import { defineStore } from 'pinia'
export const useCommonStore = defineStore(
  'yqbj-common',
  () => {
    // 验证码冷却时间管理
    const coolDown: Ref<number> = ref(0)
    const setCoolDown = (newCoolDown: number) => {
      coolDown.value = newCoolDown
    }
    const getCoolDown = () => {
      return coolDown
    }
    const coolDownInterval: Ref<any> = ref(null) // 冷却定时器
    const setCoolDownInterval = (newInterval: any) => {
      coolDownInterval.value = newInterval
    }
    const getCoolDownInterval = () => {
      return coolDownInterval
    }
    const removeCoolDownInterval = () => {
      coolDownInterval.value = null
    }
    return {
      coolDown,
      setCoolDown,
      getCoolDown,
      coolDownInterval,
      setCoolDownInterval,
      getCoolDownInterval,
      removeCoolDownInterval
    }
  },
  {
    persist: true
  }
)
